// components/goodCat/goodCat.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    goods: {
      type: Array,
      value: []
    },
    goodCat: {
      type: String,
      value: ''
    },
    show: {
      type: Boolean
    }
  },
  lifetimes: {
    // created: function () {
    //   this.setHeight()
    // }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    toDetail: function (e) {
      const id = e.currentTarget.dataset.goodid;
      wx.navigateTo({
        url: `/pages/gdetail/gdetail?goodid=${id}`,
      })
    },
    setHeight() {
      setTimeout(() => {
        const query = wx.createSelectorQuery().in(this)
        query.selectAll('.good_img').boundingClientRect(r => {
          console.log(r);
          for (let i = 0; i < r.length; i++) {
            r[i].height = r[i].width
          }
        }).exec(res => {
          for (let i = 0; i < res.length; i++) {
            res[i].height = res[i].width
          }
        });
      }, 500)
    },
    toGcDetail() {
      const goodCat = this.properties.goodCat
      wx.navigateTo({
        url: `/pages/gcdetail/gcdetail?goodc=${goodCat}`,
      })
    }
  }
})